package com.xszx.servlet.user.address;

import com.xszx.bean.Address;
import com.xszx.dao.AddressDao;
import com.xszx.dao.UserDao;
import com.xszx.dao.impl.AddressDaoImpl;
import com.xszx.dao.impl.UserDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/GetAddressServlet")
public class GetAddressServlet extends HttpServlet {
    static AddressDao addressDao = new AddressDaoImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");

        Integer id = Integer.parseInt(req.getParameter("id"));

        Address address = addressDao.getAddress(id);
        req.setAttribute("address", address);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
